package com.gjun.struts.util;

import java.util.List;
import java.util.TreeMap;

import net.sf.json.JSONArray;

import com.gjun.struts.bean.BookJsonBean;
import com.gjun.struts.bean.CategoryJsonBean;
import com.gjun.struts.bean.GjunMainTypeJson2Bean;
import com.gjun.struts.bean.GjunMainTypeJsonBean;
import com.gjun.struts.bean.GjunNewsJsonBean;
import com.gjun.struts.bean.GjunRoleJsonBean;
import com.gjun.struts.bean.GjunsystemPrivilege;
import com.gjun.struts.bean.GjunsystemUserJsonBean;
import com.gjun.struts.bean.GjunsystemUserJsonBean2;
import com.gjun.struts.bean.ItemJsonBean;
import com.gjun.struts.bean.OrderJsonBean;

public class JSONHelper {
	
	public static String prisToJson(List<GjunsystemPrivilege> pris) throws Throwable{
		JSONArray object = JSONArray.fromObject(pris);
		return object.toString();
	}
	
	public static String roleToJson(List<GjunRoleJsonBean> roles) throws Throwable{
		JSONArray object = JSONArray.fromObject(roles);
		return object.toString();
	}
	
	public static String usersToJson(List<GjunsystemUserJsonBean> beans) throws Throwable{
		JSONArray object = JSONArray.fromObject(beans);
		return object.toString();
	}
	
	public static String usersToJson2(List<GjunsystemUserJsonBean2> beans) throws Throwable{
		JSONArray object = JSONArray.fromObject(beans);
		return object.toString();
	}
	
	public static String mainTypesToJson(List<GjunMainTypeJsonBean> mTypes) throws Throwable{
		JSONArray object = JSONArray.fromObject(mTypes);
		return object.toString();
	}
	
	public static String mainTypesToJson2(List<GjunMainTypeJson2Bean> mTypes) throws Throwable{
		JSONArray object = JSONArray.fromObject(mTypes);
		return object.toString();
	}
	
	public static String newsToJson(List<GjunNewsJsonBean> news) throws Throwable{
		JSONArray object = JSONArray.fromObject(news);
		return object.toString();
	}
	
	public static String newsToJson(TreeMap<Integer, String> news) throws Throwable{
		JSONArray object = JSONArray.fromObject(news);
		return object.toString();
	}
	
	public static String categoryToJson(List<CategoryJsonBean> categories) throws Throwable{
		JSONArray object = JSONArray.fromObject(categories);
		return object.toString();
	}
	
	public static String bookToJson(List<BookJsonBean> books){
		JSONArray object = JSONArray.fromObject(books);
		return object.toString();
		
	}
	
	public static String orderToJson(List<OrderJsonBean> orders){
		JSONArray object = JSONArray.fromObject(orders);
		return object.toString();
	}
	
	public static String itemToJson(List<ItemJsonBean> items){
		JSONArray object = JSONArray.fromObject(items);
		return object.toString();
	}
	
	
	
}
